package com.link.base.base.approval.service;

import com.link.base.base.approval.model.Flow;
import com.link.base.base.approval.model.OtherFlowInfo;
import com.link.base.base.approval.exception.ApprovalNeedUserException;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.BasicServiceException;

import java.util.List;
/**
 * Copyright  hande Company. All Rights Reserved.
 *
 * @author  unknwon
 * @date:   2018/11/8 14:46
 * @version 1.0
 */

public interface FlowService extends BasicService<Flow> {

    /**
     * 分页查询活动信息
     *
     * @param record
     * @return
     * @throws  BasicServiceException
     * @throws  Exception
     */
    public List<Flow> queryFlowListPage(Flow record) throws BasicServiceException, Exception;


    /**
     * 分页查询已流程
     *
     * @param record
     * @return
     * @throws  BasicServiceException
     * @throws  Exception
     */
    public List<Flow> queryFlowedListPage(Flow record) throws BasicServiceException, Exception;

    /**
     * 根据流程记录对象id查询流程
     *
     * @param record
     * @return
     * @throws  BasicServiceException
     * @throws  Exception
     */
    public List<Flow> queryFlowByObjId(Flow record) throws BasicServiceException, Exception;


    /**
     * 更新流程头，下个节点信息
     *
     * @param record
     * @throws BasicServiceException
     * @throws Exception
     */
    public void nextNodeUpdate(Flow record) throws BasicServiceException, Exception;


    /**
     * 审批同意
     *
     * @param flowId
     * @param comments
     * @param userId
     * @param otherInfo
     * @throws Exception
     * @throws ApprovalNeedUserException
     */
    public void agreeApproval(Long flowId, String comments, Long userId, OtherFlowInfo otherInfo) throws ApprovalNeedUserException, Exception;


    /**
     * 审批同意并结束
     *
     * @param flowId
     * @param comments
     * @param otherInfo
     * @throws Exception
     */
    public void endApproval(Long flowId, String comments, OtherFlowInfo otherInfo) throws Exception;


    /**
     * 审批拒绝
     *
     * @param flowId
     * @param comments
     * @throws Exception
     */
    public void refuseApproval(Long flowId, String comments) throws Exception;

    /**
     * 审批转发
     *
     * @param flowId
     * @param comments
     * @param userId
     * @throws Exception
     */
    public void goApproval(Long flowId, String comments, Long userId) throws Exception;
    /**
     * 创建流程
     * @param objectId 对象ID
     * @param type 审批类型
     * @param userId 指定下一审批人ID（为null则不指定）
     * @param moreFlowName 审批流名称
     * @param accntId
     * @param approvalDetail
     * @throws Exception
     */

    public void createFlow(Long objectId, String type,Long userId,String moreFlowName,Long accntId,String approvalDetail) throws Exception;

    /**
     * 查询我的申请流程
     *
     * @param entity
     * @return
     * @throws  Exception
     */
    public List<Flow> queryMyFlowListPage(Flow entity) throws Exception;

    /**
     * 查询我的正运行的申请流程
     *
     * @param entity
     * @return
     * @throws  Exception
     */
    public List<Flow> queryMyRunFlowListPage(Flow entity) throws Exception;

    void withdrawApproval(Long flowId, String comments, OtherFlowInfo otherInfo) throws Exception;
}
